﻿using EcommerceRabbit.API.Application.Command.Trace;
using EcommerceRabbit.Servies.traceability;
using MediatR;

namespace EcommerceRabbit.API.Application.CommandHandler.Trace
{
    public class TraceAddCommandHandler : IRequestHandler<TraceAddCommand, int>
    {
        private readonly ITraceServices services;

        public TraceAddCommandHandler(ITraceServices services)
        {
            this.services = services;
        }

        public Task<int> Handle(TraceAddCommand request, CancellationToken cancellationToken)
        {
            return services.AddTrace(new Ecommerce.Domain.Dto.TraceDTO() { Firm=request.Firm,Shelf=request.Shelf,Images=request.Images,license=request.license,Mid=request.Mid,TName=request.TName,GoodNo=request.GoodNo,Tid=request.Tid });
        }
    }
}
